cmake_minimum_required(VERSION 3.29)
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
project(VolumeRending CXX C)
set(CXX_STANDARD 20)
# 设置vcpkg的工具链文件
# set(CMAKE_TOOLCHAIN_FILE D:/Gitee/vcpkg/scripts/buildsystems/vcpkg.cmake CACHE STRING "")
add_subdirectory(glad)
set(CUDA_ENABLE FALSE)
if(CUDA_ENABLE)
    enable_language(CUDA)
endif()
find_package(glfw3 CONFIG REQUIRED)

file(GLOB IMGUI_SRC_LIST "ext/imgui/*.cpp" "ext/imgui/*.h")
add_library(imgui STATIC ${IMGUI_SRC_LIST})
# target_include_directories(imgui PRIVATE ${glfw_INCLUDE_DIRS})
target_link_libraries(imgui PRIVATE glfw)


set(COMMON_SRCS 
src/cuda_sphere.h
src/glshower.h 
src/cuda_lib.h
src/ShapeObject.h
src/math.h)

if (CUDA_ENABLE)
    add_executable(raymarching ${COMMON_SRCS} src/sample_raymarching.h src/sample_raymarching.cu)
    add_executable(atmosphere ${COMMON_SRCS} src/sample_atmosphere.h src/sample_atmosphere.cu)
else()
    add_executable(raymarching ${COMMON_SRCS} src/sample_raymarching.h src/sample_raymarching.cpp)
    add_executable(atmosphere ${COMMON_SRCS} src/sample_atmosphere.h src/sample_atmosphere.cpp)
endif()
target_include_directories(raymarching PRIVATE glad/include ext/imgui)
target_link_libraries(raymarching PRIVATE glfw glad imgui)
target_include_directories(atmosphere PRIVATE glad/include ext/imgui)
target_link_libraries(atmosphere PRIVATE glfw glad imgui)
if (CUDA_ENABLE)
    target_compile_definitions(raymarching PRIVATE CUDA_ENABLE)
    target_compile_definitions(atmosphere PRIVATE CUDA_ENABLE)
endif()